import { SystemMsg, SystemMsgType } from '@entity/system_msg';
import { Component, Vue } from 'vue-property-decorator'
import JoinProjectRequest from './join_project/request/Index.vue';
import JoinProjectResponse from './join_project/response/Index.vue';
import AddFriendRequest from './add_friend/request/Index.vue';
import AddFriendResponse from './add_friend/response/Index.vue';

@Component({
    components: {
        JoinProjectRequest, JoinProjectResponse, AddFriendRequest, AddFriendResponse
    }
})
export class SystemMsgView extends Vue {

    /**
     * 获取消息列表，会对 time 字段进行降序排序
     */
    private get msgList(): Array<SystemMsg> {
        return this.$store.getters.systemMsgList().quicksort('time', 'DOWN');
    }

    /** 
     * 判断当前消息是不是加入项目的申请
     */
    private isJoinProjectRequest(type: string) {
        return SystemMsgType != undefined && type == SystemMsgType.JOIN_PROJECT_REQUEST;
    }

    /** 
     * 判断当前消息是不是加入项目的响应
     */
    private isJoinProjectResponse(type: string) {
        return SystemMsgType != undefined && type == SystemMsgType.JOIN_PROJECT_RESPONSE;
    }

    /** 
     * 判断当前消息是不是添加好友的申请
     */
    private isAddFriendRequest(type: string) {
        return SystemMsgType != undefined && type == SystemMsgType.ADD_FRIEND_REQUEST;
    }

    /** 
     * 判断当前消息是不是添加好友的响应
     */
    private isAddFriendResponse(type: string) {
        return SystemMsgType != undefined && type == SystemMsgType.ADD_FRIEND_RESPONSE;
    }

}